import asyncio
import time
async def func1():
    print("你好，张发富")
    # time.sleep(3)   #当程序出现同步操作的时候，异步就中断了
    await asyncio.sleep(3)  # 异步操作代码
    print("你好，张发富")

async def func2():
    print("你好，王建国")
    # time.sleep(3)
    await asyncio.sleep(2)
    print("你好，王建国")

async def func3():
    print("你好，李雪琴")
    # time.sleep(3)
    await asyncio.sleep(4)
    print("你好，李雪琴")

async def main():
    #第一种
    # f1 = func1()
    # # await一般放在协程对象前面
    # await f1
# 第二种推荐
    tasks = [
        asyncio.create_task(func1()),
        asyncio.create_task(func2()),
        asyncio.create_task(func3()),
    ]
    await asyncio.wait(tasks)



if __name__ == '__main__':
    t1 = time.time()
    asyncio.run(main())
    t2 = time.time()
    print(t2 - t1)